// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using Elastic.Transport;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch.Ilm
{
	public sealed class IlmMoveToStepRequestParameters : RequestParameters<IlmMoveToStepRequestParameters>
	{
	}

	public sealed partial class IlmMoveToStepRequest : PlainRequestBase<IlmMoveToStepRequestParameters>
	{
		public IlmMoveToStepRequest(Elastic.Clients.Elasticsearch.IndexName index) : base(r => r.Required("index", index))
		{
		}

		internal override ApiUrls ApiUrls => ApiUrlsLookups.IndexLifecycleManagementMoveToStep;
		protected override HttpMethod HttpMethod => HttpMethod.POST;
		protected override bool SupportsBody => true;
		[JsonInclude]
		[JsonPropertyName("current_step")]
		public Elastic.Clients.Elasticsearch.Ilm.StepKey? CurrentStep { get; set; }

		[JsonInclude]
		[JsonPropertyName("next_step")]
		public Elastic.Clients.Elasticsearch.Ilm.StepKey? NextStep { get; set; }
	}

	public sealed partial class IlmMoveToStepRequestDescriptor<TDocument> : RequestDescriptorBase<IlmMoveToStepRequestDescriptor<TDocument>, IlmMoveToStepRequestParameters>
	{
		internal IlmMoveToStepRequestDescriptor(Action<IlmMoveToStepRequestDescriptor<TDocument>> configure) => configure.Invoke(this);
		public IlmMoveToStepRequestDescriptor(Elastic.Clients.Elasticsearch.IndexName index) : base(r => r.Required("index", index))
		{
		}

		public IlmMoveToStepRequestDescriptor(TDocument document) : this(typeof(TDocument))
		{
		}

		internal IlmMoveToStepRequestDescriptor()
		{
		}

		internal override ApiUrls ApiUrls => ApiUrlsLookups.IndexLifecycleManagementMoveToStep;
		protected override HttpMethod HttpMethod => HttpMethod.POST;
		protected override bool SupportsBody => true;
		public IlmMoveToStepRequestDescriptor<TDocument> Index(Elastic.Clients.Elasticsearch.IndexName index)
		{
			RouteValues.Required("index", index);
			return Self;
		}

		private Elastic.Clients.Elasticsearch.Ilm.StepKey? CurrentStepValue { get; set; }

		private StepKeyDescriptor CurrentStepDescriptor { get; set; }

		private Action<StepKeyDescriptor> CurrentStepDescriptorAction { get; set; }

		private Elastic.Clients.Elasticsearch.Ilm.StepKey? NextStepValue { get; set; }

		private StepKeyDescriptor NextStepDescriptor { get; set; }

		private Action<StepKeyDescriptor> NextStepDescriptorAction { get; set; }

		public IlmMoveToStepRequestDescriptor<TDocument> CurrentStep(Elastic.Clients.Elasticsearch.Ilm.StepKey? currentStep)
		{
			CurrentStepDescriptor = null;
			CurrentStepDescriptorAction = null;
			CurrentStepValue = currentStep;
			return Self;
		}

		public IlmMoveToStepRequestDescriptor<TDocument> CurrentStep(StepKeyDescriptor descriptor)
		{
			CurrentStepValue = null;
			CurrentStepDescriptorAction = null;
			CurrentStepDescriptor = descriptor;
			return Self;
		}

		public IlmMoveToStepRequestDescriptor<TDocument> CurrentStep(Action<StepKeyDescriptor> configure)
		{
			CurrentStepValue = null;
			CurrentStepDescriptor = null;
			CurrentStepDescriptorAction = configure;
			return Self;
		}

		public IlmMoveToStepRequestDescriptor<TDocument> NextStep(Elastic.Clients.Elasticsearch.Ilm.StepKey? nextStep)
		{
			NextStepDescriptor = null;
			NextStepDescriptorAction = null;
			NextStepValue = nextStep;
			return Self;
		}

		public IlmMoveToStepRequestDescriptor<TDocument> NextStep(StepKeyDescriptor descriptor)
		{
			NextStepValue = null;
			NextStepDescriptorAction = null;
			NextStepDescriptor = descriptor;
			return Self;
		}

		public IlmMoveToStepRequestDescriptor<TDocument> NextStep(Action<StepKeyDescriptor> configure)
		{
			NextStepValue = null;
			NextStepDescriptor = null;
			NextStepDescriptorAction = configure;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (CurrentStepDescriptor is not null)
			{
				writer.WritePropertyName("current_step");
				JsonSerializer.Serialize(writer, CurrentStepDescriptor, options);
			}
			else if (CurrentStepDescriptorAction is not null)
			{
				writer.WritePropertyName("current_step");
				JsonSerializer.Serialize(writer, new StepKeyDescriptor(CurrentStepDescriptorAction), options);
			}
			else if (CurrentStepValue is not null)
			{
				writer.WritePropertyName("current_step");
				JsonSerializer.Serialize(writer, CurrentStepValue, options);
			}

			if (NextStepDescriptor is not null)
			{
				writer.WritePropertyName("next_step");
				JsonSerializer.Serialize(writer, NextStepDescriptor, options);
			}
			else if (NextStepDescriptorAction is not null)
			{
				writer.WritePropertyName("next_step");
				JsonSerializer.Serialize(writer, new StepKeyDescriptor(NextStepDescriptorAction), options);
			}
			else if (NextStepValue is not null)
			{
				writer.WritePropertyName("next_step");
				JsonSerializer.Serialize(writer, NextStepValue, options);
			}

			writer.WriteEndObject();
		}
	}

	public sealed partial class IlmMoveToStepRequestDescriptor : RequestDescriptorBase<IlmMoveToStepRequestDescriptor, IlmMoveToStepRequestParameters>
	{
		internal IlmMoveToStepRequestDescriptor(Action<IlmMoveToStepRequestDescriptor> configure) => configure.Invoke(this);
		public IlmMoveToStepRequestDescriptor(Elastic.Clients.Elasticsearch.IndexName index) : base(r => r.Required("index", index))
		{
		}

		internal IlmMoveToStepRequestDescriptor()
		{
		}

		internal override ApiUrls ApiUrls => ApiUrlsLookups.IndexLifecycleManagementMoveToStep;
		protected override HttpMethod HttpMethod => HttpMethod.POST;
		protected override bool SupportsBody => true;
		public IlmMoveToStepRequestDescriptor Index(Elastic.Clients.Elasticsearch.IndexName index)
		{
			RouteValues.Required("index", index);
			return Self;
		}

		private Elastic.Clients.Elasticsearch.Ilm.StepKey? CurrentStepValue { get; set; }

		private StepKeyDescriptor CurrentStepDescriptor { get; set; }

		private Action<StepKeyDescriptor> CurrentStepDescriptorAction { get; set; }

		private Elastic.Clients.Elasticsearch.Ilm.StepKey? NextStepValue { get; set; }

		private StepKeyDescriptor NextStepDescriptor { get; set; }

		private Action<StepKeyDescriptor> NextStepDescriptorAction { get; set; }

		public IlmMoveToStepRequestDescriptor CurrentStep(Elastic.Clients.Elasticsearch.Ilm.StepKey? currentStep)
		{
			CurrentStepDescriptor = null;
			CurrentStepDescriptorAction = null;
			CurrentStepValue = currentStep;
			return Self;
		}

		public IlmMoveToStepRequestDescriptor CurrentStep(StepKeyDescriptor descriptor)
		{
			CurrentStepValue = null;
			CurrentStepDescriptorAction = null;
			CurrentStepDescriptor = descriptor;
			return Self;
		}

		public IlmMoveToStepRequestDescriptor CurrentStep(Action<StepKeyDescriptor> configure)
		{
			CurrentStepValue = null;
			CurrentStepDescriptor = null;
			CurrentStepDescriptorAction = configure;
			return Self;
		}

		public IlmMoveToStepRequestDescriptor NextStep(Elastic.Clients.Elasticsearch.Ilm.StepKey? nextStep)
		{
			NextStepDescriptor = null;
			NextStepDescriptorAction = null;
			NextStepValue = nextStep;
			return Self;
		}

		public IlmMoveToStepRequestDescriptor NextStep(StepKeyDescriptor descriptor)
		{
			NextStepValue = null;
			NextStepDescriptorAction = null;
			NextStepDescriptor = descriptor;
			return Self;
		}

		public IlmMoveToStepRequestDescriptor NextStep(Action<StepKeyDescriptor> configure)
		{
			NextStepValue = null;
			NextStepDescriptor = null;
			NextStepDescriptorAction = configure;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (CurrentStepDescriptor is not null)
			{
				writer.WritePropertyName("current_step");
				JsonSerializer.Serialize(writer, CurrentStepDescriptor, options);
			}
			else if (CurrentStepDescriptorAction is not null)
			{
				writer.WritePropertyName("current_step");
				JsonSerializer.Serialize(writer, new StepKeyDescriptor(CurrentStepDescriptorAction), options);
			}
			else if (CurrentStepValue is not null)
			{
				writer.WritePropertyName("current_step");
				JsonSerializer.Serialize(writer, CurrentStepValue, options);
			}

			if (NextStepDescriptor is not null)
			{
				writer.WritePropertyName("next_step");
				JsonSerializer.Serialize(writer, NextStepDescriptor, options);
			}
			else if (NextStepDescriptorAction is not null)
			{
				writer.WritePropertyName("next_step");
				JsonSerializer.Serialize(writer, new StepKeyDescriptor(NextStepDescriptorAction), options);
			}
			else if (NextStepValue is not null)
			{
				writer.WritePropertyName("next_step");
				JsonSerializer.Serialize(writer, NextStepValue, options);
			}

			writer.WriteEndObject();
		}
	}
}